{
  LX Layer module

  Based on modo's SDK lxlayer.h which is:

  Copyright (c) 2008-2012 Luxology LLC

  Permission is hereby granted, free of charge, to any person obtaining a
  copy of this software and associated documentation files (the "Software"),
  to deal in the Software without restriction, including without limitation
  the rights to use, copy, modify, merge, publish, distribute, sublicense,
  and/or sell copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following conditions:

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.   Except as contained
  in this notice, the name(s) of the above copyright holders shall not be
  used in advertising or otherwise to promote the sale, use or other dealings
  in this Software without prior written authorization.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  DEALINGS IN THE SOFTWARE.

}

{
  Copyright (c) 2012 David Ballesteros and Jameel Halabi

  This unit is part of the BLAISEmodo wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}


unit Lx_Layer;

{$mode objfpc}{$H+}

interface

uses
  Lx_Result, Lx_VMath;

const
  LXa_LAYERSCAN             = 'layerscan'   ;
  LXa_LAYERSERVICE          = 'layerservice';
  LXa_SCENE1SERVICE         = 'sceneservice';

  LXi_LAYER_PRIMARY         = 0;
  LXi_LAYER_FOREGROUND      = 1;
  LXi_LAYER_BACKGROUND      = 2;
  LXi_LAYER_ALL             = 3;
  LXf_LAYER_FOREGROUND      = 1;
  LXf_LAYER_BACKGROUND      = 2;
  LXf_LAYER_MAIN            = 4;

  LXf_LAYERSCAN_ACTIVE      = $001;
  LXf_LAYERSCAN_BACKGROUND  = $002;
  LXf_LAYERSCAN_PRIMARY     = $004;
  LXf_LAYERSCAN_ALL         = LXf_LAYERSCAN_ACTIVE or LXf_LAYERSCAN_BACKGROUND;

  LXf_LAYERSCAN_MARKVERTS   = $010;
  LXf_LAYERSCAN_MARKEDGES   = $020;
  LXf_LAYERSCAN_MARKPOLYS   = $040;
  LXf_LAYERSCAN_MARKDVRTS   = $080;

  LXf_LAYERSCAN_MARKALL     = LXf_LAYERSCAN_MARKVERTS or
                              LXf_LAYERSCAN_MARKEDGES or
                              LXf_LAYERSCAN_MARKPOLYS or
                              LXf_LAYERSCAN_MARKDVRTS   ;

  LXf_LAYERSCAN_WRITEMESH   = $100;

  LXf_LAYERSCAN_EDIT        = LXf_LAYERSCAN_ACTIVE    or
                              LXf_LAYERSCAN_WRITEMESH or
                              LXf_LAYERSCAN_MARKALL     ;

  LXf_LAYERSCAN_EDIT_POLYS  = LXf_LAYERSCAN_ACTIVE    or
                              LXf_LAYERSCAN_WRITEMESH or
                              LXf_LAYERSCAN_MARKPOLYS   ;

  LXf_LAYERSCAN_EDIT_VERTS  = LXf_LAYERSCAN_ACTIVE    or
                              LXf_LAYERSCAN_WRITEMESH or
                              LXf_LAYERSCAN_MARKVERTS   ;

  LXf_LAYERSCAN_EDIT_EDGES  = LXf_LAYERSCAN_ACTIVE    or
                              LXf_LAYERSCAN_WRITEMESH or
                              LXf_LAYERSCAN_MARKEDGES   ;

  LXf_LAYERSCAN_EDIT_DVRTS  = LXf_LAYERSCAN_ACTIVE    or
                              LXf_LAYERSCAN_WRITEMESH or
                              LXf_LAYERSCAN_MARKDVRTS   ;

  LXf_LAYERSCAN_EDIT_POLVRT = LXf_LAYERSCAN_ACTIVE    or
                              LXf_LAYERSCAN_WRITEMESH or
                              LXf_LAYERSCAN_MARKPOLYS or
                              LXf_LAYERSCAN_MARKVERTS   ;

  LXfXFRMSCAN_WEIGHT        = $01;
  LXfXFRMSCAN_ALTCENTER     = $02;
  LXfXFRMSCAN_ALTAXIS       = $04;

  LXu_LAYERSCAN             = '{097DB669-91C3-11D9-8EA2-000A956C2E10}';
  LXu_LAYERSERVICE          = '{F12B06AA-BF92-4585-800E-45AB99D47A20}';
  LXu_TRANSFORMSCAN         = '{6DD4BC9B-BEDC-46B9-B5AC-850A06AD5EEB}';
  LXu_SCENE1SERVICE         = '{11D99CDC-F662-40FF-9AC3-B76E59C8DEB0}';

type
  ILxLayerService = interface
  [LXu_LAYERSERVICE]
    function ScriptQuery           (  out VObj                  ) : LxResult;
    function SetScene              (      Scene       : IUnknown) : LxResult;
    function Scene                 (      XCin        : PPointer) : LxResult;
    function Count                 (      Count       : PUInt32 ) : LxResult;
    function Name                  (      Index       : UInt32  ;
                                    const Name        : PPChar  ) : LxResult;
    function Slot                  (      Index       : UInt32  ;
                                          Slot        : PInteger) : LxResult;
    function Item                  (      Index       : UInt32  ;
                                          Item        : PPointer) : LxResult;
    function Mesh                  (      Index       : UInt32  ;
                                          Mesh        : PPointer) : LxResult;
    function Flags                 (      Index       : UInt32  ;
                                          Flags       : PInteger) : LxResult;
    function Pivot                 (      Index       : UInt32  ;
                                          Pivot       : PDouble ) : LxResult;
    function PatchSubdivision      (      Index       : UInt32  ;
                                          Level       : PInteger) : LxResult;
    function Bounds                (      Index       : UInt32  ;
                                          Min         : PDouble ;
  				          Max         : PDouble ) : LxResult;
    function CurveSmoothAngle      (      Index       : UInt32  ;
                                          Angle       : PDouble ) : LxResult;
    function SplinePatchSubdivision(      Index       : UInt32  ;
                                          Level       : PInteger) : LxResult;
    function ItemLookup            (      Mode        : Integer ;
                                          Item_       : IUnknown;
  					  Index       : PInteger) : LxResult;
    function NameLookup            (      Mode        : Integer ;
                                    const Name_       : PChar   ;
  					  Index       : PInteger) : LxResult;
    function LayerParent           (      Index       : Integer ;
                                          ParentIndex : PInteger) : LxResult;
    function LayerChildCount       (      Index       : Integer ;
                                          Num         : PInteger) : LxResult;
    function LayerChild            (      Index       : Integer ;
                                          ChildNumber : Integer ;
  					  ChildIndex  : PInteger) : LxResult;
    function LayerVMapCount        (      Num         : PInteger) : LxResult;
    function LayerVMap             (      Index       : UInt32  ;
                                      out VObj                  ) : LxResult;
    function LayerClipCount        (      Num         : PInteger) : LxResult;
    function LayerClip             (      Index       : UInt32  ;
                                      out VObj                  ) : LxResult;
    function LayerMaterialCount    (      Num         : PInteger) : LxResult;
    function LayerMaterial         (      Index       : UInt32  ;
                                      out VObj                  ) : LxResult;
    function LayerPartCount        (      Num         : PInteger) : LxResult;
    function LayerPart             (      Index       : UInt32  ;
                                    const Part        : PPChar  ) : LxResult;
    function LayerSelSetCount      (      &Type       : UInt32  ;
                                          Num         : PInteger) : LxResult;
    function LayerSelSet           (      &Type       : UInt32  ;
                                          Index       : UInt32  ;
  				    const SelSet      : PPChar  ) : LxResult;
    function LayerTextureCount     (      Layer       : Integer ;
                                          Num         : PInteger) : LxResult;
    function LayerTexture          (      Layer       : Integer ;
                                          Index       : UInt32  ;
  				      out VObj                  ) : LxResult;
    function LayerTagTextureCount  (      Layer       : Integer ;
                                          &Type       : UInt32  ;
  				    const Tag         : PChar   ;
                                          Num         : PInteger) : LxResult;
    function LayerTagTexture       (      Layer       : Integer ;
                                          &Type       : UInt32  ;
  				    const Tag         : PChar   ;
  				          Index       : UInt32  ;
       				      out VObj                  ) : LxResult;
    function LayerVertexCount      (      Mode        : Integer ;
                                          Num         : PInteger) : LxResult;
    function LayerVertex           (      Mode        : Integer ;
                                          Index       : UInt32  ;
  				      out VObj                  ) : LxResult;
    function LayerPolyCount        (      Mode        : Integer ;
                                          Num         : PInteger) : LxResult;
    function LayerPoly             (      Mode        : Integer ;
                                          Index       : UInt32  ;
                                      out VObj                  ) : LxResult;
    function LayerEdgeCount        (      Mode        : Integer ;
                                          Num         : PInteger) : LxResult;
    function LayerEdge             (      Mode        : Integer ;
                                          Index       : UInt32  ;
       				      out VObj                  ) : LxResult;
    function ScanAllocate          (      Flags_      : UInt32  ;
                                      out VObj                  ) : LxResult;
    function CurrentMap            (      &Type       : LXtID4  ;
                                    const Name_       : PPChar  ) : LxResult;
    function XfrmAllocate          (      ToolVec     : IUnknown;
                                      out VObj                  ) : LxResult;
  end;

  ILxLayerScan = interface
  [LXu_LAYERSCAN]
    function Apply                              : LxResult;
    function Count        (    Count : PUInt32) : LxResult;
    function GetState     (    Index : UInt32 ;
                               State : PUInt32) : LxResult;
    function MeshItem     (    Index : UInt32 ;
                           out VObj           ) : LxResult;
    function MeshAction   (    Index : UInt32 ;
                           out VObj           ) : LxResult;
    function MeshBase     (    Index : UInt32 ;
                           out VObj           ) : LxResult;
    function MeshInstance (    Index : UInt32 ;
                           out VObj           ) : LxResult;
    function MeshEdit     (    Index : UInt32 ;
                           out VObj           ) : LxResult;
    function SetMeshChange(    Index ,
                               Edits : UInt32 ) : LxResult;
  end;

  ILxTransformScan = interface
  [LXu_TRANSFORMSCAN]
    function Enumerate      (Visitor : IUnknown  ) : LxResult;
    function Flags                                 : UInt32  ;
    function Position                              : PSingle ;
    function SetPosition    (Pos     : LXtFVector) : LxResult;
    function Weight                                : Double  ;
    function AlternateCenter(Center  : LXtFVector) : LxResult;
    function AlternateAxis  (Matrix  ,
                             Inverse : LXtMatrix ) : LxResult;
  end;

  ILxScene1Service = interface
  [LXu_SCENE1SERVICE]
    function ScriptQuery       (out VObj               ) : LxResult;
    function ItemWorldTransform(    Locator : IUnknown ;
                                    Time    : Double   ;
   			            Xfrm    : LXtMatrix;
  				    Pos     : LXtVector) : LxResult;
    function ItemWorldRotation (    Locator : IUnknown ;
                                    Time    : Double   ;
  				    Xfrm    : LXtMatrix) : LxResult;
  end;

implementation

end.

